//
//  LDYVisitorTableViewController.swift
//  李东阳微博
//
//  Created by 李东阳 on 16/4/16.
//  Copyright © 2016年 李东阳. All rights reserved.
//

import UIKit

class LDYVisitorTableViewController: UITableViewController {

    
        //MARK: -  判断用户是否登录
    var islogin:Bool = LDYUserAccountTools.userAccountTools.isLogin
    
    var visitorView: LDYvisitorView?

    override func loadView() {
        
       islogin ? super.loadView(): setupView()
        
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }

    
        //MARK: -   登录 和 注册 按钮 的点击事件

   @objc private func login(){
    
    let oAuthVc = LDYOAuthViewController()
    
    presentViewController( UINavigationController(rootViewController: oAuthVc), animated: true, completion: nil)
    
    }
    
        //MARK: -  导航栏设置
    private func setupNavigation(){
        
       navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "login")
        
        
    }

    
        //MARK: -  初始化view

    func setupView(){
        
        
            //MARK: -  导航栏设置
        setupNavigation()
    
      visitorView = LDYvisitorView()
        
       visitorView?.loginClosure = {
        
            print("注册 登录按钮点击事件")
        
        self.login()
            
        }
        
        view = visitorView
        
    }
    
}
